package com.yiqi.zhiyuan.feature.certification.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.yiqi.zhiyuan.entity.vo.BrandChildVO;
import com.yiqi.zhiyuan.entity.vo.CarBrandVO;
import com.yiqi.zhiyuan.feature.certification.contract.BrandContract;
import com.yiqi.zhiyuan.feature.certification.dependencies.brand.DaggerBrandModelComponent;
import com.yiqi.zhiyuan.framework.api.ApiLib;
import com.yiqi.zhiyuan.framework.api.CarApi;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * @ProjectName: ZhiYuan
 * @Description: 注册model
 * @Author: lijuwen
 * @CreateDate: 2019/3/13 13:07
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/13 13:07
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */


public class BrandModel implements BrandContract.Model {
    @Inject
    CarApi api;

    public BrandModel() {
        DaggerBrandModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<List<CarBrandVO>> doQueryCarBrands() {
        return api.queryCarBrands().compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<List<BrandChildVO>> doQueryCarBrandModel(String bcode) {
        return api.queryCarBrandModel(bcode).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}

